ATSUFindFontName

Obtains the index and font name of the first font in a name table with a particular font name code, language, platform, and script.

OSStatus ATSUFindFontName (
                     ATSUFontID iFontID,
                     FontNameCode iFontNameCode,
                     FontPlatformCode iFontNamePlatform,
                     FontScriptCode iFontNameScript,
                     FontLanguageCode iFontNameLanguage,
                     ByteCount iMaximumNameLength,
                     Ptr oName,
                     ByteCount *oActualNameLength,
                     ItemCount *oFontNameIndex);
iFontID
A value of type ATSUFontID. Pass the ID of the font whose particular font name you are searching for.

iFontNameCode
A value of type FontNameCode. Pass the type of the font name string you are searching for. See Font Name Code Constants for a description of possible values.

iFontNamePlatform
A value of type FontPlatformCode. Pass the encoding of the font name string you are searching for. See Font Name Platform Constants for a description of possible values. You can pass the kFontNoPlatform constant if you do not care about the encoding of a font name. In this case, ATSUFindFontName will pass back the first font in the name table matching the other font name parameters.

iFontNameScript
A value of type FontScriptCode. Pass the script ID of the font name string. Depending upon the font name platform, see Macintosh Platform Script Code Constants, Microsoft Platform Script Code Constants, or Unicode Platform Script Code Constants for a description of possible values. You can pass the kFontNoScript constant if you do not care about the script ID. In this case, ATSUFindFontName will pass back the first font in the name table matching the other font name parameters.

iFontNameLanguage
A value of type FontLanguageCode. Pass the language of the font name string you are searching for. See Font Name Language Constants for a description of possible values. You can pass the kFontNoLanguage constant if you do not care about the language of the font name. In this case, ATSUFindFontName will pass back the first font in the name table matching the other font name parameters.

iMaximumNameLength
The maximum length of the font name. Typically, this is equivalent to the size of the buffer allocated to contain the font name pointed to by the oName parameter. To determine this length, see the discussion below.

oName
A pointer to a buffer. Before calling ATSUFindFontName, pass a pointer to memory that you have allocated for this buffer. On return, the buffer contains the font name string. If the buffer you allocate is not large enough, ATSUFindFontName passes back a partial string. You cannot pass NULL for this parameter.

oActualNameLength
A pointer to a count. On return, the actual length of the font name string. This may be greater than the value passed in the iMaximumNameLength parameter. You should check this value to make sure that you allocated enough memory for the buffer. You cannot pass NULL for this parameter.

oFontNameIndex
A pointer to a count. On return, the 0-based index of the font name in the font name table.

function result
A result code. The result code kATSUNotSetErr indicates that the font has no name in its name table matching the given parameters. The result code kATSUInvalidFontErr indicates that the specified font does not correspond to any installed font. For a list of other ATSUI-specific result codes, see Result Codes.
DISCUSSION
The ATSUFindFontName function obtains the index and font name of the first font in a name table with a particular font name code, language, platform, and script. If you want to find the index and name of the first font in a name table with a particular font name code, language, platform, and script, call the function ATSUFindFontFromName. If you want to find, for an indexed font name, the font name and information about the name like type, platform, script ID, and language, call the function ATSUGetIndFontName.

The best way to use ATSUFindFontName is to call it twice:

  1. Pass the ID of the font whose name table you are searching in the iFontID parameter, NULL for the oName parameter, and 0 for the other parameters. ATSUFindFontName returns the length of the font name string in the oActualNameLength parameter.

  2. Allocate enough space for a font name buffer of the returned size, then call the function again, passing a pointer in the oName parameter; on return, the pointer references the font name string.
VERSION NOTES
Available beginning with ATSUI 1.0.

© 2000 Apple Computer, Inc. – (Last Updated 25 Jan 00)